package com.hzcx.app.simplechat.ui.login;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.base.BaseActivity;
import com.hzcx.app.simplechat.ui.login.contract.ForgetPwdContract;
import com.hzcx.app.simplechat.ui.login.presenter.ForgetPwdPresenter;
import com.hzcx.app.simplechat.view.MainBlueConfirmButton;
import com.hzcx.app.simplechat.view.MainPwdEditText;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 忘记密码
 */
public class ForgetPwdActivity extends BaseActivity<ForgetPwdPresenter> implements ForgetPwdContract.View {

    public static final String INTENT_PHONE = "INTENT_PHONE";
    public static final String INTENT_CODE = "INTENT_CODE";
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.iv_title_right)
    ImageView ivTitleRight;
    @BindView(R.id.tv_title_right)
    TextView tvTitleRight;
    @BindView(R.id.tv_tips)
    TextView tvTips;
    @BindView(R.id.et_pwd)
    MainPwdEditText etPwd;
    @BindView(R.id.iv_pwd_state)
    ImageView ivPwdState;
    @BindView(R.id.btn_commit)
    MainBlueConfirmButton btnCommit;


    @Override
    public int getLayout() {
        return R.layout.activity_forget_pwd;
    }

    @Override
    public void initPresenter() {
        mPresenter = new ForgetPwdPresenter();
    }

    @Override
    public void initView() {
        tvTitle.setText("忘记密码");
        etPwd.setIvPwdState(ivPwdState);
        btnCommit.setEditText(etPwd, 6);
    }

    @Override
    public void initData() {

        btnCommit.setOnClickListener(view -> mPresenter.resetPwd(ForgetPwdActivity.this, etPwd.getText().toString(), getIntent().getStringExtra(INTENT_CODE),
                getIntent().getStringExtra(INTENT_PHONE)));

    }

    /**
     * 密码重置成功
     */
    @Override
    public void resetSuccess() {
        showError("修改成功");
        finish();
    }
}
